#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<signal.h>
#include<sys/time.h>
#include<fcntl.h>
#include<unistd.h> 
#include<pthread.h>

void* myfunc(void* p){

	while(1){
		printf("pthread: this is %lu\n", pthread_self());
	}
	pthread_exit((void*) 666);

}

int main(int argc, char* args[])
{
	pthread_t tid;
	int ret;
	printf("father: this is pid %d\n", getpid());
	ret = pthread_create(&tid, NULL, myfunc, NULL);
	if(ret){
		perror("pthread_creat error");
		exit(1);
	}
	sleep(1);
	ret = pthread_cancel(tid);
	if(ret){
		perror("pthread_cancel error");
		exit(1);
	}
	void* retval;
	ret = pthread_join(tid, &retval);
	if(ret){
		perror("pthread_join error");
		exit(1);
	}
	printf("join %d\n", (long long)retval);
	return 0;
}
